package com.sky.controller.system;

import com.sky.controller.BaseController;
import com.sky.dto.FeedBackDto;
import com.sky.dto.FeedBackPageDto;
import com.sky.service.FeedBackService;
import com.sky.vo.AjaxResult;
import com.sky.vo.DataGridView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;

/**
 * @author majinan
 */
@RestController
@RequestMapping("system/feedBack")
public class FeedBackController extends BaseController {

    @Autowired
    private FeedBackService service;

    /**
     * 分页查询
     */
    @GetMapping("listFeedBackForPage")
    public AjaxResult listUserForPage(FeedBackPageDto dto){
        DataGridView gridView = this.service.selectList(dto);
        return AjaxResult.success("查询成功",gridView.getData(),gridView.getTotal());
    }
    /**
     * 添加
     */
    @PostMapping("addFeedBack")
    public AjaxResult addFeedBack(@Validated FeedBackDto dto) {
        return AjaxResult.toAjax(this.service.insertFeedBack(dto));
    }

    /**
     * 修改
     */
    @PutMapping("updateFeedBack")
    public AjaxResult updateFeedBack(@Validated FeedBackDto dto) {
        return AjaxResult.toAjax(this.service.updateFeedBack(dto));
    }

    /**
     * 删除
     */
    @DeleteMapping("deleteByIds/{ids}")
    public AjaxResult deleteByIds(@PathVariable @Validated @NotEmpty(message = "要删除的ID不能为空") Long[] ids) {
        return AjaxResult.toAjax(this.service.deleteFeedBack(ids));
    }


}
